home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / share / hplip / ui4 / settingsdialog.py < prev    next >
Encoding:
Python Source  |  2009-04-14  |  3.1 KB  |  94 lines

  1. # -*- coding: utf-8 -*-
  2. #
  3. # (c) Copyright 2001-2008 Hewlett-Packard Development Company, L.P.
  4. #
  5. # This program is free software; you can redistribute it and/or modify
  6. # it under the terms of the GNU General Public License as published by
  7. # the Free Software Foundation; either version 2 of the License, or
  8. # (at your option) any later version.
  9. #
  10. # This program is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. # GNU General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU General Public License
  16. # along with this program; if not, write to the Free Software
  17. # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
  18. #
  19. # Author: Don Welch
  20. #
  21.  
  22. # Local
  23. from base.g import *
  24. from base.codes import *
  25. from ui_utils import *
  26.  
  27. # Qt
  28. from PyQt4.QtCore import *
  29. from PyQt4.QtGui import *
  30. from settingsdialog_base import Ui_SettingsDialog_base
  31.  
  32.  
  33.  
  34. class SettingsDialog(QDialog, Ui_SettingsDialog_base):
  35.     def __init__(self, parent=None):
  36.         QDialog.__init__(self, parent)
  37.         self.setupUi(self)
  38.  
  39.         self.connect(self.SetDefaultsButton, SIGNAL("clicked()"),  self.SetDefaultsButton_clicked)
  40.  
  41.         self.user_settings = UserSettings()
  42.         self.user_settings.load()
  43.  
  44.         self.SystemTraySettings.initUi(self.user_settings.systray_visible,
  45.                                        self.user_settings.polling,
  46.                                        self.user_settings.polling_interval,
  47.                                        self.user_settings.device_list)
  48.  
  49.         self.updateControls()
  50.  
  51.  
  52.     def updateControls(self):
  53.         self.AutoRefreshCheckBox.setChecked(self.user_settings.auto_refresh)
  54.         self.AutoRefreshRateSpinBox.setValue(self.user_settings.auto_refresh_rate) # min
  55.         if self.user_settings.auto_refresh_type == 1:
  56.             self.RefreshCurrentRadioButton.setChecked(True)
  57.         else:
  58.             self.RefreshAllRadioButton.setChecked(True)
  59.  
  60.         self.ScanCommandLineEdit.setText(self.user_settings.cmd_scan)
  61.         self.SystemTraySettings.systray_visible = self.user_settings.systray_visible
  62.         self.SystemTraySettings.updateUi()
  63.  
  64.  
  65.     def updateData(self):
  66.         self.user_settings.systray_visible = self.SystemTraySettings.systray_visible
  67.         self.user_settings.cmd_scan = unicode(self.ScanCommandLineEdit.text())
  68.         self.user_settings.auto_refresh = bool(self.AutoRefreshCheckBox.isChecked())
  69.  
  70.         if self.RefreshCurrentRadioButton.isChecked():
  71.             self.user_settings.auto_refresh_type = 1
  72.         else:
  73.             self.user_settings.auto_refresh_type = 2
  74.  
  75.         self.user_settings.auto_refresh_rate = self.AutoRefreshRateSpinBox.value()
  76.  
  77.  
  78.     def SetDefaultsButton_clicked(self):
  79.         self.user_settings.loadDefaults()
  80.         self.updateControls()
  81.  
  82.  
  83.     def accept(self):
  84.         self.updateData()
  85.         self.user_settings.save()
  86.         QDialog.accept(self)
  87.  
  88.         # TODO: Need a way to signal hp-systray if systray_visible has changed
  89.  
  90.     def __tr(self,s,c = None):
  91.         return qApp.translate("SettingsDialog",s,c)
  92.  
  93.  
  94.